package com.coocaa.ops.api.common.validator;

import com.coocaa.ops.api.v1.policy.model.PolicyModel;

/**
 * @author tangminghong
 * @date 2020-06-22
 * @see com.coocaa.ops.common.core.biz.policygroup.constant.PolicyGroupCategoryConstants
 */
public class PolicyValidator {

    /**
     *
     *
     * @param policy
     * @return
     */
    public static Integer getPolicyCategory(PolicyModel policy) {
        return isFormalPolicy(policy) ? 1 : 2;
    }


    /**
     * 走正式策略
     *
     * 策略为空 或者 策略分类不等于【2】-正式策略
     *
     *
     * @param policy
     * @return
     */
    public static boolean isFormalPolicy(PolicyModel policy) {
        return null == policy || policy.getCategory() != 2;
    }

    public static boolean isFormalPolicy(Integer policyCategory) {
        return null == policyCategory || policyCategory != 2;
    }

    /**
     * 走测试策略
     *
     * 策略分类【2】-测试策略
     *
     *
     * @param policy
     * @return
     */
    public static boolean isTestPolicy(PolicyModel policy) {
        return null != policy && policy.getCategory() == 2;
    }

    public static boolean isTestPolicy(Integer policyCategory) {
        return null != policyCategory && policyCategory == 2;
    }

}
